Recommendation And Prescription
View Recommendation
Once the consultation is fulfilled and the recommendation is done by the doctor
The recommendation data will be available and included in the Consultation
data
So using getConsultationInfo
with the consultation id you can view the recommendation data
const response = {
id: 123,
userId: 999999999,
question: "I want to consult a doctor on ...",
medium: "chat",
status: "closed",
isFulfilled: 1,
recommendation: {
id: 1,
consultation_id: 123,
created_at: 'date',
data: {
lab: {
lab: [
{ name: "lab_name" },
// ...
]
},
drug: {
fdaDrug: [
{
name: 'name',
dosage: 'dosage',
duration: 10, // Days
howToUse: 'how_to_use',
frequency: 'frequency',
tradeName: 'trade_name',
dosageForm: 'dosage_form',
dosageUnit: 'dosage_unit',
packageSize: 'package_size',
packageType: 'package_type',
strengthValue: 'strength_value',
relationWithFood: 'relation_with_food',
specialInstructions: 'special_instructions',
routeOfAdministration: 'route_of_administration'
},
// ...
]
},
icd10: {
symptom: [
{
code: 'symptop_code',
name: 'symptop_name',
}
// ...
],
diagnosis: [
{
code: 'diagnosis_code',
name: 'diagnosis_name',
}
// ...
]
},
followUp: [
{ name: 'follow_up_name' }
// ...
],
doctorReferral: {
name: 'referral_name'
},
postCallAnswer: [
{
answer: 'post_call_answer',
question: 'post_call_question'
}
],
},
},
// ... other data
}
Download Prescription
You can get the prescription by using getPrescription
with the consultationId
Check the code below that includes using the getPrescription
and save the PDF file
note : if the prescription for the consultation is generated it will return else it will be null
ApiService.getPrescription(id, object : ApiCallback<Response> {
override fun onSuccess(response: Response) {
val inputStream = response.body?.byteStream()
if (inputStream != null) {
savePdfToFile(inputStream, "Prescription.pdf")
}
}
override fun onFailure(error: String?) {
}
override fun onRequestError(error: String?) {
}
})
private fun savePdfToFile(inputStream: InputStream, fileName: String): File {
val downloadDirectory =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
val downloadPath = downloadDirectory.absolutePath
val outputFile = File(downloadPath, fileName)
try {
if (!outputFile.exists()) {
outputFile.createNewFile()
}
FileOutputStream(outputFile).use { outputStream ->
val buffer = ByteArray(4 * 1024) // Adjust buffer size as needed
var read: Int
while (inputStream.read(buffer).also { read = it } != -1) {
outputStream.write(buffer, 0, read)
}
outputStream.flush()
}
} catch (e: IOException) {
e.printStackTrace()
} finally {
inputStream.close()
}
return outputFile
}